﻿CREATE FUNCTION [dbo].[GetToken_Ex]
	(
@Path nvarchar(max),
@Left bit,
@Divider nvarchar(128) = '\'
	)
RETURNS nvarchar(max)
AS
BEGIN

DECLARE @Pos int

SET @Pos = CHARINDEX(@Divider,@Path)

IF @Pos = 0
	RETURN CASE @Left WHEN 1 THEN @Path ELSE '' END

RETURN CASE @Left WHEN 1 THEN LEFT(@Path,@Pos-1) ELSE RIGHT(@Path,dbo.LEN(@Divider)-@Pos) END
END





